這篇介紹如何實作DatabaseContract,主要用於對接view與presenter
public interface DatabaseContract {
interface view{
void addSuccess();
void addError();
void getSuccess(String getId,
String getRoomNumber,
Boolean getPlayer1OnlineState,
Boolean getPlayer2OnlineState,
String getMoveState,
HashMap<String,Object> getChessboardData,
HashMap<String,Object> getChessmanMoveData,
String getTurn,
HashMap<String,Object> getPawnMove1,
HashMap<String,Object> getPawnMove2,
HashMap<String,Object> getCastlingMove1,
HashMap<String,Object> getCastlingMove2,
String getDate,
String getPlayer1message,
String getPlayer2message,
String getWinPlayer);
void getError();
void uploadSuccess();
void uploadError();
void deleteSuccess();
void deleteError();
}
interface presenter{
void addData(String roomNumber,
Boolean player1OnlineState,
Boolean player2OnlineState,
String moveState,
HashMap<String,Object> chessboardData,
HashMap<String,Object> chessmanMoveData,
String turn,
HashMap<String,Object> pawnMove1,
HashMap<String,Object> pawnMove2,
HashMap<String,Object> castlingMove1,
HashMap<String,Object> castlingMove2,
String date,
String player1message,
String player2message,
String winPlayer);
void getData(String roomNumber);
void uploadData(String id,
String key,
Object newValue);
void deleteData(String id);
}
}
這樣我們就能成功在各個activity中回調firebase的方法了